<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/classes/CommonHelper.class.jsp"%>
<%@ include file="/classes/DBHelper.class.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%

	String loginId=(String)(session.getAttribute("loginId")==null?"":session.getAttribute("loginId"));
	if(nullOrEmpty(loginId)){
		out.print("<script>alert(\"请登陆后操作！\");</script>");
		out.print("<script>window.location.href = 'http://htgl.cnsn.gov.cn/cas/login';</script>");
		return;
	}
	
	//获取部门ID
	String dept_code = "";
	String sqlDept = "select t2.code_name from cms_user t1,cms_department t2 where t1.dept_id = t2.dept_id and login_id = ?";
	Map<String,Object> user = getObject(sqlDept,new Object[]{loginId});
	if(null!=user)
		dept_code = (String)user.get("code_name");

	String hzd = getParameter(request,"hzd");
	String status = getParameter(request,"status");
	String sql = "select * from APP_SUGGESTION_BOX where bm_id = ?";
	List<Object> params = new ArrayList<Object>();
	params.add(dept_code);
	if(!nullOrEmpty(hzd)){
		sql += " and hzd = ?";
		params.add(hzd);
	}
	
	if(!nullOrEmpty(status)){
		if("1".equals(status)){
			sql += " and hftime is not null";	
		}else{
			sql += " and hftime is null";
		}
	}
	
	sql +=" order by addtime desc";
	
	int currentPage = 1; 
	if(!nullOrEmpty(getParameter(request,"currentPage"))){
		currentPage = Integer.parseInt(getParameter(request,"currentPage"));
	}
	
	List<Map<String,Object>> list = queryForListPage(sql,params,currentPage,15);
	int total = queryForPageCount(sql,params);
	
	Map<String,Integer> pageMap = new HashMap<String,Integer>();
	pageMap.put("currentPage",currentPage);
	pageMap.put("total",total);
	request.setAttribute("page",pageMap);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form action="xxgkyjx_list.jsp?r=<%=new Date().getTime() %>" method="post" name="xxgkyjx_listForm">
	<table width="100%">
		<tr>
			<td>序号</td><td>标题</td><td>姓名</td><td>联系电话</td><td>留言时间</td>
		</tr>
		<c:forEach items="<%=list %>" var="info" varStatus="i">
		
		<tr>
			<td>${i.index+1 }</td>
			<td><a href="xxgkyjx_hf.jsp?hzd=${info.hzd }&r=<%=new Date().getTime()%>">
			<c:if test="${empty info.title }">无标题</c:if>
			${info.title }</a> </td>
			<td>${info.xingm }</td><td>${info.lxdh }</td><td>
			<c:if test="${null!=info.addtime }">
			<fmt:formatDate value="${info.addtime }" pattern="yyyy-MM-dd"/>
			</c:if>
			</td>
		</tr>
		</c:forEach>
		<tr>
			<td colspan="5">
			<jsp:include page="/common/page.jsp" >
		    		<jsp:param value="${page.currentPage }" name="currentPage"/>
					<jsp:param value="${page.total }" name="totalRecord"/>
					<jsp:param value="15" name="pageSize"/>
					<jsp:param value="xxgkyjx_listForm" name="formName"/>
					<jsp:param value="<%=new Date().getTime() %>" name="r"/>
		    	</jsp:include>
			</td>
		</tr>
	</table>
	</form>
</body>
</html>